package com.atguigu02.singleton;

/**
 * @author NoobMaster69  * @date 2024/5/31 0031 星期五 15:32
 */
public class GirlFriendTest {
}

//懒汉式
class GirlFriend{
    //1.构造器私有化
    private GirlFriend(){}
    //2.声明当前实例
    //4.此属性也必须修饰static
    private static GirlFriend instance = null;
    //3.通过getX 获取当前实例，如果未创建则创建
    public static GirlFriend getInstance() {
        if (instance == null){
            instance = new GirlFriend();
        }
        return instance;
    }
}
